#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define int long long 
using ll = long long;
ll n, k, ans;
ll a[29], vis[29];
bool check(ll a)
{if (a < 2) return false;
    for (int i = 2; i * i <= a; i++)
        if (a % i == 0)
            return false;
    return true;
}
void dfs(int id, int sum, int cnt)
{
    if (cnt == k)
    {
        if (check(sum))
        
            ans++;
        
        return;
    }
    for (ll i = id; i <= n; i++)
    {
        dfs(i + 1, sum + a[i], cnt + 1);
    }
    return;
}
void solve()
{
    cin >> n >> k;
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    dfs(1, 0, 0);
    cout << ans << endl;
}
signed main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
